package leetcode.linkedlist.model;


public class ListNode {
    public int val;
    public ListNode next;

    public ListNode(int value) {
        this.val = value;
    }

    @Override
    public String toString() {
        ListNode cur = this;
        StringBuilder printable = new StringBuilder();
        while (cur != null) {
            printable.append(cur.val).append(" -> ");
            cur = cur.next;
        }
        return printable + "null";
    }
}
